package ua.com.alus.resvac.crm.domen.entities;

import net.sourceforge.stripes.action.FileBean;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;

/**
 * PhotoEntity
 * Created by Usatov Alexey
 */
@Entity
@Table(name = "ACC_PHOTO")
public class Photo extends BaseEntity implements Serializable {

    @Column(name = "FK_ACCOUNT_UUID", insertable = false, updatable = false)
    private String accountUUID;

    @Transient
    private FileBean pictureBean;

    @Lob
    @Column(name = "PICTURE")
    private byte[] picture;

    public FileBean getPictureBean() {
        return pictureBean;
    }

    public void setPictureBean(FileBean pictureBean) {
        this.pictureBean = pictureBean;
    }

    public byte[] getPicture() {
        return picture;
    }

    public void setPicture(byte[] picture) {
        this.picture = picture;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "FK_ACCOUNT_UUID", referencedColumnName = "PK_UUID")
    private Account account;

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    public String getAccountUUID() {
        return accountUUID;
    }

    public void setAccountUUID(String accountUUID) {
        this.accountUUID = accountUUID;
    }
}
